package com.iona.json.builders;

import java.util.List;

import com.iona.domain.Purview;
import com.iona.json.JSONArray;
import com.iona.json.JSONBuilder;
import com.iona.json.JSONException;

public class PurviewBuilder extends JSONBuilder {

	private final List<Purview> purviews;

	public PurviewBuilder(List<Purview> findAll) {
		this.purviews = findAll;
	}

	@Override
	public Object build() throws JSONException {
		JSONArray root = new JSONArray();
		for (Purview p : purviews) {
			JSONArray arr = new JSONArray();
			arr.put(p.getId());
			arr.put(p.getName());
			root.put(arr);
		}
		return root;
	}

	@Override
	public String name() {
		return PurviewBuilder.class.getSimpleName();
	}

}
